package com.ruoyi.system.config;

import com.ruoyi.common.config.AppConfig;
import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class RedissonConfig {


    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        String redisConfigStr = "redis://" + AppConfig.REDIS_HOST + ":" + AppConfig.REDIS_PORT;
        log.info("RedissonConfig redissonClient redisConfigStr:{}", redisConfigStr);
        config.useSingleServer()
                .setAddress(redisConfigStr);
        return Redisson.create(config);
    }


}
